package com.example.lots_of_demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.lots_of_demo.model.REnum;
import com.example.lots_of_demo.model.Role;
import com.example.lots_of_demo.po.PagePo;
import com.example.lots_of_demo.service.RoleService;
import com.example.lots_of_demo.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : LZJ
 * @description : code for LZJ
 * @date : 2021/2/16
 */
@RestController
@RequestMapping("/role")
public class RoleController extends BaseController{

    @Autowired
    private RoleService roleService;

    @GetMapping("/getRolesPage")
    @PreAuthorize("hasAuthority('RES_getRolesPage')")
    public R getRolesPage(PagePo pagePo){
        Page page = new Page<Role>();
        page.setSize(pagePo.getSize()).setPages(pagePo.getPage());
        Page result = roleService.page(page);
        return R.createSuccess(REnum.RSuccessResponse.SELECT_SUCCESS_RESPONSE, result);
    }

}
